package com.ccc.picture.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 项目相关参数
 *
 * @author superC
 * @version 1.0.0
 * @date 2022/11/11
 */

@Component
@ConfigurationProperties(prefix = "project")
public class MyProjectProperties {

    private static String artifactId;
    private static String version;
    private static String description;

    public static String getArtifactId() {
        return artifactId;
    }

    public static String getVersion() {
        return version;
    }

    public static String getDescription() {
        return description;
    }

    /**
     * 说明：构建set方法，不能配置static；
     * spring在注入的时候，需要调用set 方法，如果这个方法是静态方法，就没法动态注入了，所以只需要把get方法加入static作为静态方法即可。
     */
    public synchronized void setArtifactId(String artifactId) {
        MyProjectProperties.artifactId = artifactId;
    }

    public synchronized void setVersion(String version) {
        MyProjectProperties.version = version;
    }

    public synchronized void setDescription(String description) {
        MyProjectProperties.description = description;
    }
}
